-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace deprecated String.prototype.substr() #10243
Conversation
src/helpers/helpers.core.js
Outdated
@@ -39,7 +39,7 @@ export function isArray(value) { | |||
return true; | |||
} | |||
const type = Object.prototype.toString.call(value); | |||
if (type.substr(0, 7) === '[object' && type.substr(-6) === 'Array]') { | |||
if (type.startsWith('[object') && type.endsWith('Array]')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (type.startsWith('[object') && type.endsWith('Array]')) { | |
if (type.substring(0, 7) === '[Object]' && type.substring(type.length-6) === 'Array]') { |
Bit better performance as starts and endWith
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright I removed the startsWith and endsWith usage
String.prototype.substr() is deprecated (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) so we replace it with similar functions which aren't deprecated. Signed-off-by: Tobias Speicher <[email protected]>
I have removed my post, sorry. It was in the wrong project |
String.prototype.substr() is deprecated so we replace it with functions which work similarily but aren't deprecated.
.substr() probably isn't going away anytime soon but the change is trivial so it doesn't hurt to do it.